<?php


namespace App\Helpers;


class Utils
{
    const yan = "sadfu6jyhgfz1qwesdfgbqwesdf";

    public static function password($password)
    {
        return md5(self::yan . $password);
    }


    public static function JsontoArray($json)
    {
        return json_decode($json);
    }


    public static function ArraytoJson($array)
    {
        return json_encode($array);
    }

    public static function checkPhone($phone)
    {
        if(preg_match("/^1[345678]\d{9}$/", $phone)){
            return true;
        }

        return false;
    }

    public static function getNumber()
    {
        $yCode = array('A', 'B', 'C', 'D', 'E', 'F', 'G', 'H', 'I', 'J');
        return $yCode[intval(date('Y')) - 2011] . strtoupper(dechex(date('m'))) . date('d') . substr(time(), -5) . substr(microtime(), 2, 5) . sprintf('%02d', rand(0, 99));
    }

}